﻿

Public Class PanelZipSetter
    
    'Fields :
    Private _TargetNode As ZipNode
    Public WriteOnly Property TargetNode As ZipNode
        Set(value As ZipNode)
            Me.SuspendLayout()
            _TargetNode = value
            SetMenu(_TargetNode.Type)
            PCompression.TargetNode = _TargetNode
            PBuffering.TargetNode = _TargetNode
            PProtection.TargetNode = _TargetNode
            PComment.TargetNode = _TargetNode
            PSfxOptions.TargetNode = _TargetNode
            PSplitting.TargetNode = _TargetNode
            TSB_ZipCompression.PerformClick()
            Me.ResumeLayout()
        End Set
    End Property
    'Menu :
    Private Sub SelectPage(ByVal tsb As ToolStripButton)
        Me.SuspendLayout()
        TSB_ZipCompression.Checked = False
        TSB_ZipBuffering.Checked = False
        TSB_ZipProtection.Checked = False
        TSB_ZipSplitting.Checked = False
        TSB_ZipSfxOptions.Checked = False
        TSB_ZipComment.Checked = False
        tsb.Checked = True
        Dim page As TabPage
        Dim ctrl As Control
        If tsb.Name = "TSB_ZipCompression" Then
            page = TP_Compression
            ctrl = PCompression.KCB_Method
        ElseIf tsb.Name = "TSB_ZipBuffering" Then
            page = TP_Buffering
            ctrl = PBuffering.KCB_IOBS
        ElseIf tsb.Name = "TSB_ZipProtection" Then
            page = TP_Protection
            ctrl = PProtection.KCB_Encryption
        ElseIf tsb.Name = "TSB_ZipSplitting" Then
            page = TP_Splitting
            ctrl = PSplitting.KNUD_DesiredSplitSize
        ElseIf tsb.Name = "TSB_ZipSfxOptions" Then
            page = TP_SfxOptions
            ctrl = PSfxOptions.TC_SfxOptions
            PSfxOptions.BSHG_Product.PerformClick()
        ElseIf tsb.Name = "TSB_ZipComment" Then
            page = TP_Comment
            ctrl = PComment.KTB_Comment
        Else
            page = TP_Compression
            ctrl = PCompression.KCB_Method
        End If
        TC.SelectTab(page)
        ctrl.Select()
        Me.ResumeLayout()
    End Sub
    Private Sub TS_Menu_ItemClicked(sender As Object, e As System.Windows.Forms.ToolStripItemClickedEventArgs) Handles TS_Menu.ItemClicked
        SelectPage(CType(e.ClickedItem, ToolStripButton))
    End Sub
    Private Sub SetMenu(ByVal type As ZipType)
        Select Case type
            Case ZipType.SimpleZip
                TSB_ZipSplitting.Visible = False
                TSB_ZipSfxOptions.Visible = False
            Case ZipType.SplitZip
                TSB_ZipSplitting.Visible = True
                TSB_ZipSfxOptions.Visible = False
            Case ZipType.SfxZip
                TSB_ZipSplitting.Visible = False
                TSB_ZipSfxOptions.Visible = True
        End Select
    End Sub
    'Actions :
    Public Sub Reset()
        PCompression.Reset()
        PBuffering.Reset()
        PProtection.Reset()
        PComment.Reset()
        PSfxOptions.Reset()
        PSplitting.Reset()
        TSB_ZipCompression.PerformClick()
    End Sub
    Public Sub Cancel()
        PCompression.Cancel()
        PBuffering.Cancel()
        PProtection.Cancel()
        PComment.Cancel()
        PSfxOptions.Cancel()
        PSplitting.Cancel()
        TSB_ZipCompression.PerformClick()
    End Sub
    Public Sub Apply()
        PCompression.Apply()
        PBuffering.Apply()
        PProtection.Apply()
        PComment.Apply()
        PSfxOptions.Apply()
        PSplitting.Apply()
        _TargetNode.UpdateChildsEntrySettings()
        TSB_ZipCompression.PerformClick()
    End Sub

End Class
